package neu.soft.feignclient;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import neu.soft.vo.ResultBean;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
@Slf4j
public class FinancialServerFeignClientFallBackFactory implements FallbackFactory<FinancialServerFeignClient> {
    @Override
    public FinancialServerFeignClient create(Throwable throwable) {
        return new FinancialServerFeignClient() {
            @Override
            public ResultBean<Map<String, Object>> supply(Map<String, Object> map) {
                log.info(throwable.getMessage());
                HashMap<String, Object> objectObjectHashMap = new HashMap<>();
                objectObjectHashMap.put("error","error");
                return ResultBean.error("出错了",objectObjectHashMap);
            }
        };
    }
}
